﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace FetionLite
{
    class TimedHintManager
    {
        public delegate void SetTimedHintDelegete(string hintText);
        private static Timer _timer;
        private SetTimedHintDelegete _setTimedHintDelegate;

        public TimedHintManager(SetTimedHintDelegete setTimedHintDelegate)
        {
           _setTimedHintDelegate = setTimedHintDelegate;
        }

        public void CreateTimedHint(int timeout, string text)
        {
            _setTimedHintDelegate(text);

            //pass Timeout.Infinite then we can trigger the timer only once
            _timer = new Timer(OnTimer, null, timeout, Timeout.Infinite);
        }

        protected void OnTimer(object state)
        {
            _timer.Dispose();
            _setTimedHintDelegate("");
        }
    }
}
